/**
 * Created by liujinghao on 12/12 0012.
 *
 */

// 日游客预测
var option_day_forecast = {
    tooltip: {
        trigger: 'axis'
    },
    grid: {
        right: 20,
        left:50,
    },
    legend: {
        right: 50,
        data: ['昨日', '今日'],
        textStyle: {
            color: "#ffffff"
        }
    },
    textStyle: {
        color: "#d2d2d2"
    },
    calculable: true,
    xAxis: [
        {
            type: 'category',
            boundaryGap: false,
            axisLine: {
                lineStyle: {
                    color: '#475f79'
                }
            },
            data: ['00:00','01:00','02:00','03:00','04:00','05:00','06:00','07:00','08:00','09:00','10:00','11:00','12:00','13:00','14:00','15:00','16:00','17:00','18:00','19:00','20:00','21:00','22:00','23:00']
        }
    ],
    yAxis: [
        {
            type: 'value',
            axisLabel: {
                formatter: '{value}'
            },
            axisLine: {
                lineStyle: {
                    color: '#475f79'
                }
            },
            splitLine: {
                show: true,
                lineStyle: {
                    // 使用深浅的间隔色
                    color: ['#2f2f2f']
                }
            },
        }
    ],
    series: [
        {
            name: '昨日',
            type: 'line',
            smooth: true,
            showSymbol: true,
            symbol: 'circle',
            symbolSize: 3,
            data: [0,0,0,0,0,0,2,100,160,260,380,480,560,600,570,560,420,360,0,0,0,0,0,],
            areaStyle: {
                normal: {
                    color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                        offset: 0,
                        color: "rgba(247, 115, 121, 0.5)"
                    }, {
                        offset: 1,
                        color: "rgba(255, 255, 255, 0.2)"
                    }], false),
                }
            },
        },
        {
            name: '今日',
            type: 'line',
            smooth: true,
            showSymbol: true,
            symbol: 'circle',
            symbolSize: 3,
            itemStyle: {
                normal: {
                    color: '#4bb6fc'
                }
            },
            data: [0,0,0,0,0,0,2,100,180,280,390,490,580,620,590,540,400,320,0,0,0,0,0,],
        }
    ]
};

// function daySearch(t1, t2) {
//     var opt = {
//         type: 'get',
//         url: '/bigdata/manage/tourist/day-trend',
//         data: {},
//         callback: function (res) {
//             if (res.code == 1) {
//                 dyw.box.alert(res.msg);
//                 return false
//             }
//             setDay(res.result);
//             $("#date1").val(res.result.start_time);
//             $("#date2").val(res.result.end_time);
//         }
//     }
//     if (t1) {
//         opt.data = {
//             start_time: t1,
//             end_time: t2
//         }
//     }
//     loadData(opt)
// }
// daySearch();
// $("#search1").on('click', function () {
//     var t1 = $("#date1").val();
//     var t2 = $("#date2").val();
//     if (!t1 || !t2) {
//         dyw.box.alert('请选择查询时间');
//         return false
//     }
//     daySearch(t1, t2);
// })
// // 区域人员流量特征  静态页面显示开始
// function flowList(data) {
//     console.log(data)
//     var tpl = ` <li soda-repeat="item in list" >
//                         <i></i> <span>{{item}}</span>
//                 </li>`;
//     document.getElementById("areaFeatures").innerHTML = soda(tpl, data);
// }

// 区域人员流量特征  静态页面显示结束

// function setDay(data) {
//     option_day_forecast.xAxis[0].data = data.xAxis;
//     option_day_forecast.legend.data = data.legend;
//     var confArr = [];
//     data.data.forEach(function (val, index) {
//         if (val.dotted) {
//             var obj = $.extend(true, {}, option_day_forecast.series[1]);
//             obj.lineStyle = { normal: { type: 'dotted' } }
//         } else {
//             var obj = $.extend(true, {}, option_day_forecast.series[0]);
//         }
//         obj.name = val.name;
//         obj.data = val.data;
//         confArr.push(obj)
//     })
//     option_day_forecast.series = confArr;
//     var dayForecast = echarts.init(document.getElementById('dayForecast'));
//     dayForecast.setOption(option_day_forecast);
//     // 区域人员流量特征
//     var tpl = ` <li soda-repeat="item in list" >
//                         <i></i> <span>{{item}}</span>
//                     </li>`;
//     var fea = {
//         list: []
//     };
//     fea.list = data.features;
//     document.getElementById("areaFeatures").innerHTML = soda(tpl, fea);
// }
var dayForecast = echarts.init(document.getElementById('dayForecast'));
    dayForecast.setOption(option_day_forecast);




// 7天客流量
var option_week_forecast = {
    color: ["#4bb6fc"],
    tooltip: {
        trigger: 'axis'
    }, grid: {
        right: 20,
        left:50,
    },
    legend: {
        show: true,
        data: ['去年同期', '今年预测'],
        top: 15,
        right: 15,
        textStyle: {
            color: "#fff"
        }
    },
    calculable: true,
    xAxis: [
        {
            type: 'category',
            boundaryGap: false,
            axisLine: {
                lineStyle: {
                    color: 'rgba(255, 255, 255, 0.8)'
                }
            },
            data: ['11-09','11-10','11-11','11-12','11-13','11-14','11-15']
        }
    ],
    yAxis: [
        {
            type: 'value',
            axisLabel: {
                formatter: '{value}'
            },
            axisLine: {
                lineStyle: {
                    color: 'rgba(255, 255, 255, 0.8)'
                }
            },
            splitLine: {
                show: true,
                lineStyle: {
                    // 使用深浅的间隔色
                    color: ['#2f2f2f']
                }
            },
        }
    ],
    series: [
        {
            name: '去年同期',
            type: 'line',
            smooth: true,
            showSymbol: true,
            symbol: 'circle',
            symbolSize: 3,
            data: [13, 70, 35, 50,42, 20, 30],
            itemStyle: {
                normal: {
                    color: '#4bb6fc'
                }
            },
            areaStyle: {
                normal: {
                    color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                        offset: 0,
                        color: "rgba(19, 70, 106, 0.5)"
                    }, {
                        offset: 1,
                        color: "rgba(255, 255, 255, 0.1)"
                    }], false),
                }
            },
        },
        {
            name: '今年预测',
            type: 'line',
            smooth: true,
            showSymbol: true,
            symbol: 'circle',
            symbolSize: 3,
            data: [11, 51, 15, 30, 12,13, 25],
            itemStyle: {
                normal: {
                    color: '#fbed47',
                }
            },
        }
    ]
};
var weekForecast = echarts.init(document.getElementById('weekForecast'));
weekForecast.setOption(option_week_forecast);
loadData({
    type: 'get',
    url: '/bigdata/manage/tourist/predict7-day',
    data: {},
    callback: function (res) {
        console.log(res)
        if (res.code == 1) {
            dyw.box.alert(res.msg);
            return false
        }
        // setWeek(res.result);
    }
})
// function setWeek(data) {
//     option_week_forecast.xAxis[0].data = data.xAxis;
//     option_week_forecast.legend.data = data.legend;
//     var confArr = [];
//     data.data.forEach(function (val, index) {
//         if (val.dotted) {
//             var obj = $.extend(true, {}, option_week_forecast.series[1]);
//         } else {
//             var obj = $.extend(true, {}, option_week_forecast.series[0]);
//         }
//         //    obj.name = val.name;
//         obj.data = val.data;
//         confArr.push(obj)
//     })
//     option_week_forecast.series = confArr;
//     var weekForecast = echarts.init(document.getElementById('weekForecast'));
//     weekForecast.setOption(option_week_forecast);
// }














